package com.ruoyi.student.studenttype.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.student.studenttype.domain.Studenttype;
import com.ruoyi.student.studenttype.service.IStudenttypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生类型管理Controller
 * 
 * @author dj
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/studenttype/studenttype")
public class StudenttypeController extends BaseController
{
    @Autowired
    private IStudenttypeService studenttypeService;

    /**
     * 查询学生类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('studenttype:studenttype:list')")
    @GetMapping("/list")
    public TableDataInfo list(Studenttype studenttype)
    {
        startPage();
        List<Studenttype> list = studenttypeService.selectStudenttypeList(studenttype);
        return getDataTable(list);
    }

    /**
     * 导出学生类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('studenttype:studenttype:export')")
    @Log(title = "学生类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Studenttype studenttype)
    {
        List<Studenttype> list = studenttypeService.selectStudenttypeList(studenttype);
        ExcelUtil<Studenttype> util = new ExcelUtil<Studenttype>(Studenttype.class);
        util.exportExcel(response, list, "学生类型管理数据");
    }

    /**
     * 获取学生类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('studenttype:studenttype:query')")
    @GetMapping(value = "/{stuTypeId}")
    public AjaxResult getInfo(@PathVariable("stuTypeId") Long stuTypeId)
    {
        return success(studenttypeService.selectStudenttypeByStuTypeId(stuTypeId));
    }

    /**
     * 新增学生类型管理
     */
    @PreAuthorize("@ss.hasPermi('studenttype:studenttype:add')")
    @Log(title = "学生类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Studenttype studenttype)
    {
        return toAjax(studenttypeService.insertStudenttype(studenttype));
    }

    /**
     * 修改学生类型管理
     */
    @PreAuthorize("@ss.hasPermi('studenttype:studenttype:edit')")
    @Log(title = "学生类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Studenttype studenttype)
    {
        return toAjax(studenttypeService.updateStudenttype(studenttype));
    }

    /**
     * 删除学生类型管理
     */
    @PreAuthorize("@ss.hasPermi('studenttype:studenttype:remove')")
    @Log(title = "学生类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stuTypeIds}")
    public AjaxResult remove(@PathVariable Long[] stuTypeIds)
    {
        return toAjax(studenttypeService.deleteStudenttypeByStuTypeIds(stuTypeIds));
    }
}
